clear
%% PROBLEM
d = 2;
x_bound = repmat([-6,6],[d,1]);
OptSet.sol = [3,2;
    -2.805118,3.131312;
    -3.779310,-3.283186;
    3.584428,-1.848126];
OptSet.fval = 0;

rep = 1;

Problem.Dimension = d; % the dimension of the decision variable
Problem.LowerBound = x_bound(:,1)'; % the lower bound of the decision variable
Problem.UpperBound = x_bound(:,2)'; % the upper bound of the decision variable
Problem.ObjFunc = @ObjValue;  % the objective function
%% ALGORITHM
Algorithm.PopulationSize = 100;  % the population size of the ga
Algorithm.MaxFEs = 5000;  % the maixmal budget
% the followings are not necessary
Algorithm.F = 0.5;  % the mutation factor of the differential evolution
Algorithm.CR = 0.7;  % crossover index of the differential evolution
[ParetoFront, ParetoSet, EvaluationNum, GenerationNum] = mommop(Problem, Algorithm);
GenerationNum
EvaluationNum

%% FIGURES
if rep == 1
    if d==1
        x=x_bound(1,1):(x_bound(1,2)-x_bound(1,1))/1000:x_bound(1,2);
        z=ObjValue(x');
        z_max=max(z);
        z_min=min(z);
        figure()
        hold on
        plot(x,z)
        plot(ParetoSet,ParetoFront(:,1),'.')
        hold off
    end
    if d == 2
        figure()
        hold on
        scatter(ParetoSet(:,1),ParetoSet(:,2),2,ParetoFront(:,1),'filled');
        plot(OptSet.sol(:,1),OptSet.sol(:,2),'o')
        hold off
        xlabel('','Interpreter','latex','String','$x_1$')
        ylabel('','Interpreter','latex','String','$x_2$')
        set(gca,'Fontname','Times New Roman','FontSize',16);
    end
end
